<template>
<div class="person">
    <h2>我是兄级组件</h2>
    <h2>我有{{toy}}玩</h2>
    <h2>弟弟给了我:{{money}}</h2>
    <button>点击以后传给弟弟级组件游戏</button>
</div>
</template>
<script>
export default {
    name:"Children",
    data(){
        return{
            toy:'小霸王游戏机',
            money:''
        }
    },
    methods: {
        zouqi(value){
            console.log('孩子1',value);
            this.money = value
        }
    },
    created(){
        this.$bus.$on('wan',this.zouqi)
    },
    // mounted(){
    //     this.$bus.$on('wan',this.zouqi)
    // },
    beforeDestroy(){
        console.log('children组件销毁了',this);
        // 关闭传来的事件,减轻负担
        this.$bus.$off('wan')
    }
}
</script>

<style>
.person{
    background: skyblue;
    padding: 10px;
}
</style>